class Request {
  constructor() {
    this.baseURL = 'http://localhost:8088'
	// this.baseURL = 'http://192.168.211.1:8088' // 真机测试时需要 局域网访问 -hx
	// this.baseURL = 'http:// 172.172.9.57:8088'
  }

  post(url, data) {
    return new Promise((resolve, reject) => {
		
      uni.request({
        url: this.baseURL + url,
        method: 'POST',
        data,
        header: { 'Content-Type': 'application/json' },
        success: (res) => resolve(res.data),
        fail: (err) => reject(err)
      })
    })
  }
  
    // 添加GET方法支持
    get(url, params) {
      return new Promise((resolve, reject) => {
        uni.request({
          url: this.baseURL + url,
          method: 'GET',
          data: params, // uni.request中GET请求的参数也是通过data字段传递
          header: { 'Content-Type': 'application/x-www-form-urlencoded' },
          success: (res) => resolve(res.data),
          fail: (err) => reject(err)
        })
      })
    }
	
}

// 导出实例
export default new Request()